package com.zifeng.study.service.impl;

import com.zifeng.study.bean.User;
import com.zifeng.study.service.UserService;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.Date;

/**
 * @description 用户service实现类
 */
@DubboService(version = "${demo.service.version}")
public class UserServiceImpl implements UserService {
    @Override
    public User getUserById(long id) {
        // 测试为了方便直接写死
        User user = new User(1, "zifeng", 24, "12345678910", "广州市天河区");
        System.out.println("当前用户id为：【】" + id + "请求用户信息！");

        return user;
    }

    @Override
    public User getUserInfo(long id) {
        User user = new User();
        sleep();
        user.setId(Thread.currentThread().getId());
        user.setUserName("tst："+ new Date().getTime());
        user.setAge(18);
        user.setPhoneNumber("111111");
        user.setAddress("xxx");
        return user;
    }

    // 模拟业务耗时
    private void sleep(){
        try{
            Thread.sleep(4500);
        }catch (Exception e){
            e.printStackTrace();
        }
    }


}
